package com.gimi.cloud.bbp.dao.dao.mall;


import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.gimi.cloud.bbp.dao.dao.sys.BaseDao;
import com.gimi.cloud.bbp.dao.myMapper.MyMapper;
import com.gimi.cloud.bbp.dto.mall.MallAppBannerGroupDTO;
import com.gimi.cloud.bbp.entity.mall.MallAppBannerGroupEntity;

/**
 * banner组数据库访问层
 *
 * @author wbj
 * @version 1.0
 * @Description
 * @create 2018-01-30
 **/
public interface MallAppBannerGroupDao extends MyMapper<MallAppBannerGroupEntity>,BaseDao<MallAppBannerGroupEntity,MallAppBannerGroupDTO>{

	@Select("SELECT * FROM mall_app_banner_group bg "
			+ "WHERE LEAST(bg.abg_predict_start_time,bg.abg_start_time) < NOW() "
			+ "GROUP BY LEAST(bg.abg_predict_start_time,bg.abg_start_time) DESC LIMIT 1")
	MallAppBannerGroupDTO selectOneByNow();
	
	
	/**
	 * 获取是否有新的页面开始
	 * @return
	 */
	@Select("SELECT * FROM `mall_app_banner_group` WHERE abg_predict_start_time <= NOW() AND abg_status = 1 AND is_delete = 0 ORDER BY abg_predict_start_time DESC LIMIT 2")
	List<MallAppBannerGroupEntity> selectNowStartLimit2();
	
	@Select("SELECT * FROM `mall_app_banner_group` WHERE abg_predict_start_time >= NOW() AND abg_status = 1 AND is_delete = 0 ORDER BY abg_predict_start_time DESC LIMIT 1")
	MallAppBannerGroupDTO selectAlfter();
}
